package com.wfuhui.modules.api.controller;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wfuhui.common.utils.R;
import com.wfuhui.modules.api.annotation.LoginUser;
import com.wfuhui.modules.oms.entity.UserEntity;
import com.wfuhui.modules.oms.entity.AppointEntity;
import com.wfuhui.modules.oms.service.AppointService;

import io.swagger.annotations.Api;

@RestController
@RequestMapping("/api/appoint/")
@Api("预约接口")
public class ApiAppointController {
	
	@Autowired
	private AppointService appointService;
	
    @GetMapping("list")
    public R list(@RequestParam Map<String, Object> map){
    	List<AppointEntity> appointList = appointService.queryList(map);
        return R.ok().put("appointList", appointList);
    }
    
    
    @PostMapping("save")
    public R save(@LoginUser UserEntity user, @RequestBody AppointEntity appoint){
    	appoint.setUserId(user.getId().intValue());
    	appoint.setCreateTime(new Date());
    	appointService.save(appoint);
        return R.ok();
    }
}
